Version control

Dr Maeve Murphy Quinlan

What is version control?

  • Often described as “track changes”, although that’s not quite right
  • A super-powerful “undo” button
  • A way of working collaboratively without over-writing each other’s work
  • A way of recording exactly what you did and when

What is version control?

One way of doing version control…

What is version control?

  • We’re going to use git, which is a strangely named version control software
  • We’ll use this to explain how version control works, and why it matters
  • There are lots of other ways to do version control, but git is very widely used
    • If version control was word processing, git would be Microsoft Word

What does git do?

  • git allows you to bundle up changes to various files, and give the group of changes a unique commit hash and an explanatory message.
  • git works on a project level, so you can make a bunch of changes to different files in a folder, and then commit all those changes with a descriptive message
  • It’s recorded that you made those changes, and there’s a unique commit hash that you can quote to point at the exact state of your folder when you added those changes.

What does git do?

Old version of python-file.py

1 # This is a comment

2 import matplotlib.pyplot as plt

3 x = [1, 2, 3, 4, 5]

4 y = [3, 4, 5, 6, 7]

5 plt.scatter(x, y)

New version of python-file.py

1 # This is a comment

2 import matplotlib.pyplot as plt

3 import numpy as np

4 x = [1, 2, 3, 4, 5]

5 y = [3, 4, 5, 6, 7]

6 plt.scatter(x, y)

6 plt.plot(x, y)

Line 3 added, line 6 removed, line 6 added.

What does git do?

New version of python-file.py

1 # This is a comment

2 import matplotlib.pyplot as plt

3 import numpy as np

4 x = [1, 2, 3, 4, 5]

5 y = [3, 4, 5, 6, 7]

6 plt.scatter(x, y)

6 plt.plot(x, y)

Line 3 added, line 6 removed, line 6 added.

Associated git commit

File: python-file.py

Commit hash: u87wy9o2

Commit message: change plotting method

+++ 3 import numpy as np

— 6 plt.scatter(x, y)

+++ 6 plt.plot(x, y)